package es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions;

import es.udc.emarketapp.emarket.model.purchase.dao.SQLPurchaseDAO;
import es.udc.emarketapp.emarket.model.purchase.dao.SQLPurchaseDAOFactory;
import es.udc.emarketapp.emarket.model.purchase.vo.PurchaseVO;
import java.sql.Connection;

import es.udc.fbellas.j2ee.util.exceptions.InternalErrorException;
import es.udc.fbellas.j2ee.util.exceptions.ModelException;
import es.udc.fbellas.j2ee.util.sql.TransactionalPlainAction;

public class CreatePurchaseAction implements TransactionalPlainAction {

    private PurchaseVO purchaseVO;

    public CreatePurchaseAction(PurchaseVO purchaseVO) {
        this.purchaseVO = purchaseVO;
    }

    public Object execute(Connection connection)
            throws InternalErrorException, ModelException {

        SQLPurchaseDAO purchaseDAO = SQLPurchaseDAOFactory.getDAO();
        
            return purchaseDAO.create(connection, purchaseVO);

    }
}
